#include "biosage.h"
#include "genenetwork.h"
#include "biotablewidget.h"
#include "attributeset.h"

BioSage::BioSage(QGraphicsItem *parent) :
    QGraphicsWidget(parent)
{
//    QString path = "../../";
//#ifdef Q_OS_MAC
//    path.append("../../../");
//#endif

//    QString file1 = path + "Data/Sub_Network.sif" ;
//    QString file2 = path + "Data/Sub_Network_Attribute.txt";
    launchBioWidget(":/Sub_Network.sif");//get network
    launchBioWidget(":Sub_Network_Attribute.txt");//get table- not curr visible

    //get attributes for network
//    QList<QString> genes;
//    table->getElements( 0, genes);

//    QList<QString> att1;
//    table->getElements( 2, att1);

//    QList<QString> att2;
//    table->getElements( 3, att2);

//    QList<QString> att3;
//    table->getElements( 4, att3);

    //attributeSets.push_back( new QualAttributeSet( genes, att1, this )  );//make this parent
    //network->addAttributeSet( attributeSets[0] );//parent will be reset inside network

    //attributeSets.push_back( new QualAttributeSet( genes, att2, this )  );
    //network->addAttributeSet( attributeSets[1] );

    //attributeSets.push_back( new QualAttributeSet( genes, att3, this )  );
    QVector< QPointer<QualAttributeSet> > attributeSets;
    table->getAttributeSets(attributeSets);
    qDebug() << attributeSets.size() << endl;
    for( int i = 0; i < attributeSets.size(); i++)
    {
        attributeSets[i]->setVisible( true );
        network1->addAttributeSet( attributeSets[i] );
    }




}


void BioSage::launchBioWidget(QString filename)
{
    if( filename.endsWith(".sif"))
    {
        network1 = new GeneNetwork( filename, this );//create gene network and add it to scene by making it a child of this widget
        network2 = new GeneNetwork( filename, this );

        network1->setPos(0, 0);
        network2->setPos(200, 200);

        network1->forgeConnection( network2 );
    }
    else
    {
        table = new BioTableWidget( filename, this );
        table->setVisible(true);//for now
    }

    //    GeneNetwork *network1 = new GeneNetwork("../../../../../Data/Sub_Network.txt");
    //    network1->setPos( 0, 0 );//-350, 0 );
    //    qDebug() << "adding network to scene" << endl;
    //    scene.addItem( network1 );

    //    GeneNetwork *network2 = new GeneNetwork("../../../../../Data/Sub_Network.txt");
    //    network2->setPos( 100, 100 );//350, 0 );
    //    qDebug() << "adding network to scene" << endl;
    //    scene.addItem( network2 );

    //    network1->forgeConnection( network2 );

    //    BioTableWidget *bioTable = new BioTableWidget("../../../../../Data/Sub_Network_Attribute.txt" );
    //    bioTable->setPos(200, 200);
    //    scene.addItem( bioTable );

        //network1->forgeConnection( bioTable );
        //network2->forgeConnection( bioTable );
}

//void keyPressEvent(QKeyEvent *event)
//{

//}


//QRectF BioSage::boundingRect() const
//{
//    return QRectF(-700, -350, 1400, 700); //note- before attributes added, was width = 700
//}

//QPainterPath BioSage::shape() const
//{
//    QPainterPath path;
//    path.addRect(boundingRect());
//    return path;
//}


//void BioSage::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
//{

//}
